package main

import (
	configx "config"

	"github.com/cloudwego/kitex/pkg/discovery"
	etcd "github.com/kitex-contrib/registry-etcd"
	clientv3 "go.etcd.io/etcd/client/v3"
)

func EtcdResolver() discovery.Resolver {
	r, err := etcd.NewEtcdResolver(
		[]string{configx.EtcdEndpoints},
		etcd.WithAuthOpt(configx.EtcdUsername, configx.EtcdPassword),
		etcd.WithDialTimeoutOpt(configx.TimeOut),
	)
	if err != nil {
		panic(err)
	}
	return r
}

var etcdConfig = clientv3.Config{
	Endpoints:           []string{configx.EtcdEndpoints},
	Username:            configx.EtcdUsername,
	Password:            configx.EtcdPassword,
	RejectOldCluster:    false,
	PermitWithoutStream: false,
}
